package tienmanh.gs.goldminer.sprite;

import org.andengine.entity.modifier.LoopEntityModifier;
import org.andengine.entity.modifier.PathModifier;
import org.andengine.entity.sprite.AnimatedSprite;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.region.ITiledTextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import tienmanh.gs.goldminer.manager.ResourcesManager;
import tienmanh.gs.goldminer.scene.GameScene;
import tienmanh.gs.goldminer.util.Value;


public class Object extends AnimatedSprite
{
	
	Sprite frzzeIce;
	public boolean isFrzzeIce,ischeck;
	@Override
	protected void onManagedUpdate(float pSecondsElapsed) {
		// TODO Auto-generated method stub
		super.onManagedUpdate(pSecondsElapsed);
		if(GameScene.isFrzee && this.isVisible()){
          if(!isFrzzeIce){
        	  frzzeIce = new Sprite(0,0,getWidth(),getHeight(), ResourcesManager.getInstance().textureRegionFrzzeScreen,getVertexBufferObjectManager());
              attachChild(frzzeIce);
              ischeck = true;
              isFrzzeIce = true;
          }
          if(System.currentTimeMillis() - GameScene.getInstace().valueFrzzeTime1 > 15000 && ischeck) {
	         detachChild(frzzeIce);
	         frzzeIce = null;
	         ischeck = false;
     	 }
		}
	}
	public boolean isExplode = false;
	private boolean ispullAgainPearl = false;
	
  public boolean isIspullAgainPearl() {
		return ispullAgainPearl;
	}

	public void setIspullAgainPearl(boolean ispullAgainPearl) {
		this.ispullAgainPearl = ispullAgainPearl;
	}

public Object(float pX, float pY, float pWidth, float pHeight,
			ITiledTextureRegion pTiledTextureRegion,
			VertexBufferObjectManager pVertexBufferObjectManager , int paramInt, float paramFloat5, String paramString) {
		super(pX, pY,pWidth,pHeight, pTiledTextureRegion, pVertexBufferObjectManager);
		// TODO Auto-generated constructor stub
		this.gold = paramInt;
	    this.speed = paramFloat5;
	    this.type = paramString;
	}
  public static int stt;
  public float endX;
  public float endY;
  private int gold;
  public float rX;
  public float rY;
  private float speed;
  public void setGold(int gold) {
	this.gold = gold;
}

public void setType(String type) {
	this.type = type;
}
private String type;


  public int getGold()
  {
    return this.gold;
  }

  public float getSpeed()
  {
    return this.speed;
  }

  public String getType()
  {
    return this.type;
  }
  

  public void moveGold(boolean paramBoolean)
  {
    if (paramBoolean)
      this.speed = this.speed*2;
    PathModifier.Path localPath = new PathModifier.Path(2).to(this.endX, this.endY).to(this.rX, this.rY);
    int offRealX = (int) (endX - rX);
   	int offRealY = (int) (endY - rY);
   	float length = (float) Math.sqrt((offRealX * offRealX) + (offRealY * offRealY));
   	float velocity = speed / 1.0f; 
   	float realMoveDuration = length / velocity;
    registerEntityModifier(new LoopEntityModifier(new PathModifier(realMoveDuration, localPath), 1));
  }

  public void ngoctraiUP(int value){
	  
  }
 

  public void pullBackGold(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, boolean paramBoolean)
  {
    this.rX = paramFloat1;
    this.rY = paramFloat2;
    this.endX = paramFloat3;
    this.endY = paramFloat4;
    moveGold(paramBoolean);
  }

  public void setExplode()
  {
  }

  public void setSpeed(float paramFloat)
  {
    this.speed = paramFloat;
  }
  
  public void detachMouseGold(){
	  
  }

}

